package com.smiletrain.base;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Alarma implements Serializable {

	private static final long serialVersionUID = 8549477240765803847L;
	
	public Alarma(Long time, Caso caso) {
		this.time = time;
		this.caso = caso;
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
	public Caso getCaso() {
		return caso;
	}
	
	public void setCaso(Caso caso){
		this.caso = caso;
	}
	
 	public Long getTime() {
		return time;
	}
	
	public void setTime(Long time) {
		this.time = time;
	}
	
	public String getFecha(){
		Calendar c = new GregorianCalendar();
		c.setTime(new Date(time));
		return 
				toDiaSemana(c.get(Calendar.DAY_OF_WEEK)) + " " + 
				c.get(Calendar.DATE) + " de " +
				toMes(c.get(Calendar.MONTH));
	}

	public String getHora(){
		Calendar c = new GregorianCalendar();
		c.setTime(new Date(time));
		return
				fillZeros(c.get(Calendar.HOUR_OF_DAY)) + ":" +
				fillZeros(c.get(Calendar.MINUTE));
	}
	
	private String toDiaSemana(int i) {
		switch(i){
			case Calendar.MONDAY:    return "Lunes";
			case Calendar.TUESDAY:   return "Martes";
			case Calendar.WEDNESDAY: return "Miercoles";
			case Calendar.THURSDAY:  return "Jueves";
			case Calendar.FRIDAY:    return "Lunes";
			case Calendar.SATURDAY:  return "Sabado";
			case Calendar.SUNDAY:    return "Domingo";
		}
		return "";
	}
	
	private String toMes(int i) {
		switch(i){
			case Calendar.JANUARY:   return "Enero";
			case Calendar.FEBRUARY:  return "Febrero";
			case Calendar.MARCH:     return "Marzo";
			case Calendar.APRIL:     return "Abril";
			case Calendar.MAY:       return "Mayo";
			case Calendar.JUNE:      return "Junio";
			case Calendar.JULY:      return "Julio";
			case Calendar.AUGUST:    return "Agosto";
			case Calendar.SEPTEMBER: return "Septiembre";
			case Calendar.OCTOBER:   return "Octubre";
			case Calendar.NOVEMBER:  return "Noviembre";
			case Calendar.DECEMBER:  return "Diciembre";
		}
		return "";
	}
	
	private String fillZeros(int m){
		String sm = String.valueOf(m);
		return sm.length() == 1 ? "0" + sm : sm;
	}
	
	private int id = 0;
	private Long time;
	private Caso caso;
	
}
